package es

import (
	"context"
	"strings"
)

// 集群或者索引的监控状态
func (e *EsClient) ClusterHealth(index string) (res interface{}, err error) {
	return e.rawClient.ClusterHealth().Index(strings.Split(index, ",")...).Do(context.Background())
}

// 集群状态的元数据
func (e *EsClient) ClusterState(index, metric string) (res interface{}, err error) {
	return e.rawClient.ClusterState().Index(strings.Split(index, ",")...).Metric(strings.Split(metric, ",")...).Do(context.Background())
}

// 集群统计信息
func (e *EsClient) ClusterStats() (res interface{}, err error) {
	return e.rawClient.ClusterStats().Do(context.Background())
}

// 插件
func (e *EsClient) Plugins() (res interface{}, err error) {
	return e.rawClient.Plugins()
}

// 集群节点信息
func (e *EsClient) NodesInfo(nodeids, metric string) (res interface{}, err error) {
	return e.rawClient.NodesInfo().NodeId(strings.Split(nodeids, ",")...).Metric(strings.Split(metric, ",")...).Do(context.Background())
}

// 集群节点统计信息
func (e *EsClient) NodesStats(nodeids, metric string) (res interface{}, err error) {
	return e.rawClient.NodesStats().NodeId(strings.Split(nodeids, ",")...).Metric(strings.Split(metric, ",")...).Do(context.Background())
}

// 任务列表
func (e *EsClient) TasksList() (res interface{}, err error) {
	return e.rawClient.TasksList().Do(context.TODO())
}

// 查询任务
func (e *EsClient) TasksGetTask(taskId string) (res interface{}, err error) {
	return e.rawClient.TasksGetTask().TaskId(taskId).Do(context.TODO())
}

// 取消任务
func (e *EsClient) TasksCancel(taskId string) (res interface{}, err error) {
	return e.rawClient.TasksCancel().TaskId(taskId).Do(context.TODO())
}